<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css">
		<style type="text/css">
			html,
			body,
			.mui-content {
				background-color: white;
			}
			
			.mui-bar {
				background-color: #3B559F;
				width: 100%;
				color: #FFFFFF
			}
			
			.mui-bar a,
			.mui-bar h1 {
				color: #FFFFFF;
			}
			
			.mui-content .input1 {
				width: 75%;
				margin-left: 3%;
				border: hidden;
				margin-bottom: 0;
				font-size: 90%;
			}
			
			.mui-content .input2 {
				width: 80%;
				margin-left: 3%;
				border: hidden;
				margin-bottom: 0;
				font-size: 90%;
			}
			
			.mui-icon-arrowright {
				color: #A9A9A9;
				position: relative;
				margin-right: 0;
			}
			
			.mui-bar button {
				color: #FFFFFF;
				background-color: #3B559F;
				position: absolute;
				right: 6px;
				bottom: 5px;
				border: 0;
			}
			
			.input-div {
				border-bottom: 1px solid #E5E5E5;
				display: flex;
				align-items: center;
				font-size: 90%;
			}
			
			.mui-bar button:active {
				color: #FFFFFF;
				background-color: #3B559F!important;
			}
		</style>
	</head>

	<body>

		<header class="mui-bar mui-bar-nav" id="header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">注册</h1>
			<button type="button" id="toastBtn">完成</button>
		</header>

		<div class="mui-content">
			<p style="width: 92%;margin-left: 4%;margin-top: 3%;">请完善个人档案..一旦注册，再次修改需上传学生证，请注意填写<br /> 我们会根据您填写的信息对您您将会在不久将来被移除该平台，为您带来的不便，请理解。
			</p>

			<div id="" style="background-color: #FFFFFF;width: 92%;margin-left: 4%;">
				<div name="radioswicth" class="input-div">
					性别
					<div class="mui-input-row mui-radio mui-left">
						<label>男</label>
						<input name="radio1" type="radio" value="男">
					</div>
					<div class="mui-input-row mui-radio mui-left">
						<label>女</label>
						<input name="radio1" type="radio" value="女">
					</div>
				</div>

				<div id="toschool" onclick="toschool();" class="input-div">
					学校
					<input type="text" id="schooll" placeholder="黄河科技学院" disabled="true" class="input1" />
					<div class="mui-icon mui-icon-arrowright"></div>
				</div>

				<div class="input-div">
					专业
					<input type="text" class="input2" id="zhuanye" placeholder="网络工程" />
				</div>

				<div class="input-div">
					院系
					<input type="text" class="input2" id="yuanxi" placeholder="计算机与科学系" />
				</div>
			</div>

		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js" type="text/javascript"></script>
		<script src="../js/mui.picker.js"></script>
		<script src="../js/mui.poppicker.js"></script>
		<script src="../js/city.data.js"></script>
		<script src="../js/city.data-3.js"></script>
		<script src="../js/immersed.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();

			function toschool() {
				mui.openWindow({
					url: "searchschool.html",
					id: "searchschool.html",
					extras: {
						backnum: '0'
					}
				})
			}

			//window.onload = function() {
				//获取学校名称(纯js方法)
				//      	  var shouo = plus.webview.currentWebview().school;
				//      	  var scoolval = document.getElementById("schooll");
				//      	  var loc = shouo;
				//			  var n1 = loc.length;//地址的总长度
				//			  var n2 = loc.indexOf("=");//取得=号的位置
				//			  var text = decodeURI(loc.substr(n2+1, n1-n2));//从=号后面的内容
				//			  if (text.length < 19) {
				//			  	scoolval.value = text
				//			  }else{
				//			  	scoolval.value = ''
				//			  }
			//}

			window.addEventListener('school', function(event) {
				if(event.detail.school) {
					document.getElementById("schooll").value = event.detail.school
				}
			})

			mui.plusReady(function() {

				starbar();
				var viewwidth = document.body.clientWidth;
				var pngg = document.getElementsByClassName('input-div');
				pngg[0].style.padding = "-webkit-calc(" + viewwidth * 0.02 + "px) 0";
				pngg[1].style.padding = "-webkit-calc(" + viewwidth * 0.02 + "px) 0";
				pngg[2].style.padding = "-webkit-calc(" + viewwidth * 0.02 + "px) 0";
				pngg[3].style.padding = "-webkit-calc(" + viewwidth * 0.02 + "px) 0";

				var lyuser_Card = plus.webview.currentWebview().lyuser_Card;
				document.getElementById("toastBtn").addEventListener('tap', function() {
					var IyCollage = document.getElementById('schooll').value;
					var IyMajor = document.getElementById('zhuanye').value;
					var IyYuanXi = document.getElementById('yuanxi').value;
					//获取性别
					var choose = document.getElementsByName("radio1");
					var IySex = '';
					for(var i = 0; i < choose.length; i++) {
						if(choose[i].checked) {
							if(choose[i].value == '男') {
								IySex = 1
							} else {
								IySex = 1
							}

						}
					}

					if( IyCollage == "" || IyMajor == "" || IyYuanXi == "" || IySex == "") {
						mui.alert('所有内容都不能为空')
					} else {

						mui.ajax({
							url: 'https://www.lunyuwang.com/userController/registCollage',
							data: {
								lyuser_Card: lyuser_Card,
								lyuser_Sex: IySex,
								lyuser_Collage: IyCollage,
								lyuser_Major: IyMajor,
								lyuser_YuanXi: IyYuanXi

							},
							async: true, //将false改为true
							crossDomain: true, //强制使用5+跨域
							dataType: 'json', //服务器返回json格式数据
							type: 'get', //HTTP请求类型
							timeout: 10000, //超时时间设置为10秒；
							//processData: false,
							headers: {
								'Content-Type': 'application/x-www-form-urlencoded'
							},

							success: function(data) {
								if(data.state == 0) {
									mui.toast('网络异常，请重试');
								} else {
									mui.toast('注册成功！');
									mui.openWindow({
										url: "../index.html",
										id: "../index.html",
										createNew: true
									});

								}
							},
							error: function(xhr, type, errorThrown) {
								//异常处理；
								mui.toast('网络异常，请重试');
							}
						});
					}
				});
			});
		</script>
	</body>

</html>